//加载外部头像
class loadImage extends egret.Sprite{
    private _size:number = 73;
    private url:string="";
    public LOAD_COMPLETE:string = "loadComplete"; 
    constructor (picUrl:string,size:number=0){
        super();
        this._size = size;
        if(!picUrl) return;
        this.url = picUrl;
        this.loader = new egret.URLLoader();
        //设置加载方式为纹理
         this.loader.dataFormat = egret.URLLoaderDataFormat.TEXTURE;
        //添加加载完成侦听
         this.loader.addEventListener(egret.Event.COMPLETE,this.imageComplete,this);
		 var request: egret.URLRequest = new egret.URLRequest(picUrl);
        //开始加载
         this.loader.load(request);
    }
   public getUrl():string{
       return this.url;
   }
   private loader;
   private imageComplete(e: egret.Event): void { 
	   this.loader.removeEventListener(egret.Event.COMPLETE,this.imageComplete,this); 
       if(this._size == 0){
           this._size = 73;
       }
       var bim:egret.Bitmap=new egret.Bitmap(e.target.data);
       bim.width = this._size;
       bim.height = this._size;
       this.addChild(bim);
       this.dispatchEventWith(this.LOAD_COMPLETE,false,bim);
    }
}